package reflection.proxy;


interface ClothFactory{

    void produceCloth();
}


//代理类
class ProxyClothFactory implements ClothFactory{

    private ClothFactory factory;//用被代理类对象实例化

    public ProxyClothFactory(ClothFactory factory) {
        this.factory = factory;
    }

    @Override
    public void produceCloth() {
        System.out.println("代理工厂做一些准备工作");
        factory.produceCloth();
        System.out.println("代理工厂做一些后续的收尾工作");
    }
}

class NickClothFactory implements ClothFactory{

    @Override
    public void produceCloth() {
        System.out.println("Nick工厂做了一批衣服");
    }
}

public class StaticProxyTest {

    public static void main(String[] args) {
        //创建被代理对象
        NickClothFactory nike = new NickClothFactory();
        //创建代理对类象
        ProxyClothFactory proxyClothFactory = new ProxyClothFactory(nike);

        proxyClothFactory.produceCloth();
    }

}
